package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class RegDemo {
    public static void main(String[] args) {
        System.out.println("请输入姓名,密码,绰号,年龄");
        Scanner sc = new Scanner(System.in);
        try (Connection connection = DBUtil.getConnection();){
            Statement statement = connection.createStatement();
            String sql = "insert into user(username,password,nickname,age) values('"+sc.next()+"','"+sc.next()+"','"+sc.next()+"',"+sc.next()+")";
            int num = statement.executeUpdate(sql);
            System.out.println(num>0?"注册成功":"注册失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
